package formbeans;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.mybeans.form.FormBean;
/*
 *  Course: S09-15437 - WEB APPLICATION DEVELOPMENT 
 * 	Name: Jiale Huang
 * 	Andrew ID: jialeh
 * 	Date: 2/23/2009
 *  Assignment: Hw4
 */

public class ChangePwdForm extends FormBean {
	
    private String oldPassword;
    private String newPassword;
    private String confirmPassword;
	

	public String getOldPassword() {
		return oldPassword;
	}
	public String getNewPassword() {
		return newPassword;
	}
	public String getConfirmPassword() {
		return confirmPassword;
	}
	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}
	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}
	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

    public List<String> getValidationErrors() {
        List<String> errors = new ArrayList<String>();

        if (oldPassword == null || oldPassword.length() == 0) errors.add("Old password is required!!");
        if (newPassword == null || newPassword.length() == 0) errors.add("New password is required!!");
        if (confirmPassword == null || confirmPassword.length() == 0) errors.add("Please confirm your password!!");
        
        if(!newPassword.equals(confirmPassword)) errors.add("Your confirm password doesn't match your new password!!");
                
        return errors;
    }
}
